<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common.jsp" %>

<html>
<head>
    <meta charset="utf-8">
    <title>修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/css/public.css" media="all"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">原密码</label>
        <div class="layui-input-block">
            <input type="text" name="oldpassword" required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
            <input type="text" name="newpassword" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="${ctx}/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form'], function(){
        var form = layui.form,
        $ = layui.jquery;
        //监听提交
        form.on('submit(formDemo)', function(data){
            console.log(data)
            $.ajax({
                url:'${ctx}/admin/changePassword'
                ,method:'post'
                ,dataType:'json'
                ,data:data.field
                ,success: function(res){
                    if (res.code == 10200){
                        top.layer.msg("操作成功！");
                    }else {
                        top.layer.msg(res.message);
                    }
                }
                ,error: function () {
                    top.layer.msg("服务器繁忙,请稍后再试！");
                }
            });
            return false;
        });
    });
</script>

</body>
</html>
